<template>
  <scroll class="tab-menu" ref="tabMenuScroll">
      <div class="menu-list">
        <div v-for="(item , index) in categories"
             class="menu-list-item"
             :key="index"
             :class="{active: index === currentIndex}"
             @click="menuListItemClick(index)">
          {{item.title}}
        </div>
      </div>
  </scroll>


</template>

<script>
  import Scroll from 'components/common/scroll/Scroll'
  export default {
    name: 'TabMenu',
    components:{
      Scroll
    },
    props: {
      categories: {
        type: Array,
        default() {
          return []
        }
      }
    },
    data(){
      return {
        currentIndex: 0,
        menuLength: 0
      }
    },
    updated(){
      this.$refs.tabMenuScroll.refresh()
    },
    methods:{
      menuListItemClick(index){
        this.currentIndex = index
        this.$emit('menuListItemClick',index)
      }
    }
  }
</script>

<style scoped>
  .tab-menu {
    height: calc(100vh - 44px - 49px);
    width: 100px;
    box-sizing: border-box;

  }
  .menu-list{
    height: 100%;
    position: relative;
    margin-top: 49px;
  }
  .menu-list-item {
    background-color: #f6f6f6;
    height: 45px;
    line-height: 45px;
    text-align: center;
    font-size: 14px;
  }
  .menu-list-item.active {
    font-weight: 700;
    color: var(--color-high-text);
    background-color: #fff;
    border-left: 3px solid var(--color-high-text);
  }
</style>
